package com.ee.bruscar.configuration.maker;

import java.util.ArrayList;

import com.ee.bruscar.configuration.hint.Hint;
import com.ee.bruscar.configuration.hint.ListModelHint;
import com.ee.bruscar.configuration.hint.ModelHint;
import com.ee.bruscar.configuration.hint.lookup.HintLookup;

public class HintedListMaker implements Maker
{
	private ModelHint hint;
	private HintLookup lookup;
	
	public HintedListMaker(ModelHint modelHint, HintLookup lookup )
	{
		this.hint = modelHint;
		this.lookup = lookup;
	}

	@SuppressWarnings("unchecked")
	public Object make()
	{
		int range = getRange();
	
		ArrayList result = new ArrayList();
		
		for( int i = 0 ; i < range ; i++)
		{
			result.add( new HintedModelMaker( hint, lookup ).make() );
		}
		return result;
	}

	private int getRange()
	{
		String[] rangeArray = hint.getRange().split("-");
		
		return RandomUtil.getRandomNumber( 
				new Integer( rangeArray[0] ).intValue(),
				new Integer( rangeArray[1] ).intValue() 
			);
	}
}
